package com.company.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.company.common.annotation.Log;
import com.company.common.core.controller.BaseController;
import com.company.common.core.domain.AjaxResult;
import com.company.common.enums.BusinessType;
import com.company.system.domain.TableTodolist;
import com.company.system.service.ITableTodolistService;
import com.company.common.utils.poi.ExcelUtil;
import com.company.common.core.page.TableDataInfo;

/**
 * 待办列Controller
 * 
 * @author ruoyi
 * @date 2022-07-06
 */
@RestController
@RequestMapping("/system/todolist")
public class TableTodolistController extends BaseController
{
    @Autowired
    private ITableTodolistService tableTodolistService;

    /**
     * 查询待办列列表
     */
    @PreAuthorize("@ss.hasPermi('system:todolist:list')")
    @GetMapping("/list")
    public TableDataInfo list(TableTodolist tableTodolist)
    {
        startPage();
        List<TableTodolist> list = tableTodolistService.selectTableTodolistList(tableTodolist);
        return getDataTable(list);
    }

    /**
     * 导出待办列列表
     */
    @PreAuthorize("@ss.hasPermi('system:todolist:export')")
    @Log(title = "待办列", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TableTodolist tableTodolist)
    {
        List<TableTodolist> list = tableTodolistService.selectTableTodolistList(tableTodolist);
        ExcelUtil<TableTodolist> util = new ExcelUtil<TableTodolist>(TableTodolist.class);
        util.exportExcel(response, list, "待办列数据");
    }

    /**
     * 获取待办列详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:todolist:query')")
    @GetMapping(value = "/{todoid}")
    public AjaxResult getInfo(@PathVariable("todoid") Long todoid)
    {
        return AjaxResult.success(tableTodolistService.selectTableTodolistByTodoid(todoid));
    }

    /**
     * 新增待办列
     */
    @PreAuthorize("@ss.hasPermi('system:todolist:add')")
    @Log(title = "待办列", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TableTodolist tableTodolist)
    {
        return toAjax(tableTodolistService.insertTableTodolist(tableTodolist));
    }

    /**
     * 修改待办列
     */
    @PreAuthorize("@ss.hasPermi('system:todolist:edit')")
    @Log(title = "待办列", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TableTodolist tableTodolist)
    {
        return toAjax(tableTodolistService.updateTableTodolist(tableTodolist));
    }

    /**
     * 删除待办列
     */
    @PreAuthorize("@ss.hasPermi('system:todolist:remove')")
    @Log(title = "待办列", businessType = BusinessType.DELETE)
	@DeleteMapping("/{todoids}")
    public AjaxResult remove(@PathVariable Long[] todoids)
    {
        return toAjax(tableTodolistService.deleteTableTodolistByTodoids(todoids));
    }
}
